//
//  YLOrderViewModel.m
//  YLFinanceService
//
//  Created by she1323 on 2017/9/7.
//  Copyright © 2017年 she1323. All rights reserved.
//  订单填写

#import "YLOrderViewModel.h"
#import "YLAccountTool.h"
#import "YLMyAdressModel.h"
@implementation YLOrderViewModel

- (NSMutableArray *)groups
{
    if (!_groups) {
        _groups = [NSMutableArray array];
        
        {
            YLAccount *account = [YLAccountTool account];
            YLMyAdressModel *addressModel = account.defaultAddress;
            
            if (addressModel) {
                [_groups addObject:addressModel];
            } else {
                // 没有收货地址
                YLHaveNoAdressModel *model1 = [[YLHaveNoAdressModel alloc] init];
                model1.clickBlock = ^NSString *{
                     return nil;
                };
                 [_groups addObject:model1];
            }
        }
        
        {
            YLMallGoodModel *model = [[YLMallGoodModel alloc] init];
            [_groups addObject:model];
        }
        
        // 数量
        {
            YLOrderGoodNumberModel *model = [[YLOrderGoodNumberModel alloc] init];
            model.number = @"0";
            [_groups addObject:model];
        }
        
        // 介绍
        {
            YLOrderIntroduceModel *model = [[YLOrderIntroduceModel alloc] init];
            model.introduce = @"兑换商品将在下单后的第二个工作日寄出。请确保收货地址和电话的准确性。以免影响收货日期, 谢谢！";
            [_groups addObject:model];
        }
        
    }
    return _groups;
}

- (void)setInfoModel:(YLMallGoodModel *)infoModel
{
    _infoModel = infoModel;
    [self.groups replaceObjectAtIndex:1 withObject:infoModel];
    YLOrderGoodNumberModel *model = self.groups[2];
    model.number = infoModel.count;
}

@end
